<template>
	<view class="checkin">
		<logo-title />
		<view class="form-tip">*必须填写</view>
		<input-box label="姓名" :required="true" :value.sync="member.name" />
		<!-- <input-select label="证件类型" :required="true" :value.sync="member.cardType" :range="cardTypeList" /> -->
		<input-box label="身份证号码" :required="true" :value.sync="member.idnumber"  />
		<input-box label="职务" :required="true" :value.sync="member.position" tip="(请填写具体职位)" />
		<input-box label="移动电话" :required="true" :value.sync="member.phone" type="number" />
		<!-- <input-checkbox label="行业选择" :required="true" :value.sync="member.industry" type="text" v-show="iscompany" /> -->
		<input-select label="行业选择" :required="true" :value.sync="member.industry" :range="industryList" />
		<button class="submit-btn" type="default" @tap="save">提交</button>
	</view>
</template>

<script>
	// import checkinMixin from '@/mixins/checkin.js'
	
	export default {
		// mixins: [checkinMixin],
		data() {
			return {
				member: {
					name: '',
					idnumber: undefined,
					position: '',
					phone: undefined,
					industry: ''
				},
				industryList: ['成品制造商', '配件制造商', '经销商', '设备安装、剧场、舞台工程', '媒体单位', '其他行业']
			};
		},
		onLoad(option) {
			if (option.companyCode) {
				this.member.company_id = option.companyCode;
			}else{
				// 如果没有 companyCode，则跳转回首页
			}
		},
		
		methods: {
			save() {
				if (!this.check()) {
					return;
				}
			
				if (this.member.isUpdate != 1) {
					this.member.mid = genMid()
				}
				
				uni.request({
					url: this.url + 'add.php',
					data: this.member,
					method: 'POST',
					success: res => {
						uni.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						});
						if (res.data.code == '0') {
							const { phone, openid, mid, company_id: companyCode } = this.member
							const iscompany = 'true'
							uni.redirectTo({
								url: `../qrcode/qrcode?phone=${phone}&openid=${openid}&mid=${mid}&iscompany=${iscompany}&companyCode=${companyCode}`
							});
						}
					}
				});
			},
		}
	}
</script>

<style lang="less">
	@import url('@/common/less/vars.less');

	.checkin {
		font-size: @main-font-size;
		box-sizing: border-box;
		padding: 0 51.56rpx;
		padding-bottom: 60px;

		.form-tip {
			color: @theme-color;
			margin-top: 24px;
			margin-bottom: 10px;
		}

		.submit-btn {
			margin-top: 60px;
			width: 189.84rpx;
			height: 75rpx;
			line-height: 75rpx;
			background-color: @theme-color;
			color: #fff;
			font-size: 18px;
			border-radius: 5px;
			border: none;
		}
	}
</style>
